import axios from 'axios';
import Bus from './Bus'
//上传图片
export function uploadPic(files, icon = '') {
  let fd = new FormData();
  fd.append('icon', icon);
  fd.append('files', files);
  return new Promise((resolve, reject) => {
    Bus.$toast.loading({
      duration: 0,
      mask: true,
      message: '图片上传中...'
    });
    axios.post('https://app.wpengtao.com:8222/file/upload', fd).then(res => {
      Bus.$toast.clear();
      let r = res.data;
      if(r.code == '200'){
        resolve(r)
      }else{
        reject(res.data);
      }
    }).catch(err => {
      Bus.$toast.clear();
      reject(err);
    });
  })
}
